package com.los;

import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @program: java8
 * @description: stream特性之match
 * @author: Yujuan
 * @create: 2018-06-14 11:15
 **/
public class StreamMatch {
    public static void main(String[] args) {
        //都要匹配
        Stream<Integer> integerStream= Arrays.stream(new Integer[]{1,2,3,4,5,6,7,8,9});
        boolean result=integerStream.allMatch(integer -> integer>10);
        System.out.println(result);

        //只要有一个匹配
        integerStream= Arrays.stream(new Integer[]{1,2,3,4,5,6,7,8,9});
        result=integerStream.anyMatch(integer -> integer>6);
        System.out.println(result);

        //都不匹配
        integerStream= Arrays.stream(new Integer[]{1,2,3,4,5,6,7,8,9});
        result=integerStream.noneMatch(integer -> integer<0);
        System.out.println(result);
    }
}
